package me.zhanghai.openharmony.materialplaypausedrawable.slice;

import me.zhanghai.openharmony.materialplaypausedrawable.MaterialPlayPauseImage;
import me.zhanghai.openharmony.materialplaypausedrawable.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;

public class MainAbilitySlice extends AbilitySlice {
    MaterialPlayPauseImage mPlayPauseButton;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        mPlayPauseButton = (MaterialPlayPauseImage) findComponentById(ResourceTable.Id_play_pause);
//        mPlayPauseButton.setColor();
        mPlayPauseButton.setClickedListener(view -> {
            MaterialPlayPauseImage.State newState =
                    mPlayPauseButton.getState() == MaterialPlayPauseImage.State.Play ?
                            MaterialPlayPauseImage.State.Pause
                            : MaterialPlayPauseImage.State.Play;
            mPlayPauseButton.setState(newState);
        });

    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
